package cn.com.headfree.mouldshow.dao.impl;

import cn.com.headfree.entity.TContiStudyInfoTemp;
import cn.com.headfree.mouldshow.dao.TContiStudyInfoTempDao;
import com.gta.edu.sdk.base.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Repository("/tContiStudyInfoTempDao")
public class TContiStudyInfoTempDaoImpl extends BaseDaoImpl<TContiStudyInfoTemp> implements TContiStudyInfoTempDao {


    @Override
    public void saveInfo(TContiStudyInfoTemp tContiStudyInfo) {
        String sql = "insert into t_conti_study_info_temp (id,user_name,start_time,end_time,major,study_place,certifier,erp_no,id_card_no,type,org_id,creater_id,creater_name,create_time,updater_id,updater_name,update_time,del_sign,is_valid,audit_state,orignal_id,business_type_id,primitive_id) values ";
        StringBuilder sqlBuilder = new StringBuilder(sql);
        sqlBuilder.append("(#{id,jdbcType=VARCHAR},").append("#{user_name,jdbcType=VARCHAR},").append("#{start_time,jdbcType=DATE},")
                .append("#{end_time,jdbcType=DATE},").append("#{major,jdbcType=VARCHAR},")
                .append("#{study_place,jdbcType=VARCHAR},").append("#{certifier,jdbcType=VARCHAR},")
                .append("#{erp_no,jdbcType=VARCHAR},").append("#{id_card_no,jdbcType=VARCHAR},")
                .append("#{type,jdbcType=VARCHAR},").append("#{org_id,jdbcType=VARCHAR},").append("#{creater_id,jdbcType=VARCHAR},")
                .append("#{creater_name,jdbcType=VARCHAR},").append("#{create_time,jdbcType=DATE},")
                .append("#{updater_id,jdbcType=VARCHAR},").append("#{updater_name,jdbcType=VARCHAR},")
                .append("#{update_time,jdbcType=DATE},").append("#{del_sign,jdbcType=INTEGER},")
                .append("#{is_valid,jdbcType=INTEGER},").append("#{audit_state,jdbcType=INTEGER},")
                .append("#{orignal_id,jdbcType=VARCHAR},").append("#{business_type_id,jdbcType=VARCHAR},")
                .append("#{primitive_id,jdbcType=VARCHAR})");
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("id", tContiStudyInfo.getId());
        params.put("user_name", tContiStudyInfo.getUserName());
        params.put("start_time", tContiStudyInfo.getStartTime());
        params.put("end_time", tContiStudyInfo.getEndTime());
        params.put("major", tContiStudyInfo.getMajor());
        params.put("study_place", tContiStudyInfo.getStudyPlace());
        params.put("certifier", tContiStudyInfo.getCertifier());
        params.put("erp_no", tContiStudyInfo.getErpNo());
        params.put("id_card_no", tContiStudyInfo.getIdCardNo());
        params.put("type", tContiStudyInfo.getType());
        params.put("org_id", tContiStudyInfo.getOrgId());
        params.put("creater_id", tContiStudyInfo.getCreaterId());
        params.put("creater_name", tContiStudyInfo.getCreaterName());
        params.put("create_time", new Timestamp(new Date().getTime()));
        params.put("updater_id", tContiStudyInfo.getUpdaterId());
        params.put("updater_name", tContiStudyInfo.getUpdaterName());
        params.put("update_time", new Timestamp(new Date().getTime()));
        params.put("del_sign", 0);
        params.put("is_valid", tContiStudyInfo.getIsValid());
        params.put("audit_state", tContiStudyInfo.getAuditState());
        params.put("orignal_id", tContiStudyInfo.getOrignalId());
        params.put("business_type_id", tContiStudyInfo.getBusinessTypeId());
        params.put("primitive_id", tContiStudyInfo.getPrimitiveId());
        this.executeSql(sqlBuilder.toString(), params);
    }
}
